<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>删除学生信息</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background: #f0f2f5;
            margin: 0;
            padding: 20px;
        }
        h1 {
            text-align: center;
            color: #007bff;
        }
        .form-container {
            max-width: 500px;
            margin: 0 auto;
            background: #fff;
            padding: 20px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            border-radius: 8px;
        }
        .form-group {
            margin-bottom: 15px;
        }
        label {
            display: block;
            margin-bottom: 5px;
            color: #333;
        }
        input[type="text"], input[type="number"], button {
            width: 100%;
            padding: 10px;
            margin: 5px 0 15px 0;
            box-sizing: border-box;
            font-size: 16px;
        }
        select {
            width: 100%;
            padding: 10px;
            margin: 5px 0 15px 0;
            box-sizing: border-box;
            font-size: 16px;
        }
        button {
            background: #dc3545;
            color: white;
            border: none;
            cursor: pointer;
            border-radius: 5px;
        }
        button:hover {
            background: #c82333;
        }
    </style>
</head>
<body>
    <h1>删除学生信息</h1>
    <div class="form-container">
        <form id="deleteStudentForm">
            <div class="form-group">
                <label for="Sid">学号</label>
                <input type="text" id="Sid" name="Sid" required>
            </div>
            <div class="form-group">
                <label for="Sname">姓名</label>
                <input type="text" id="Sname" name="Sname" required>
            </div>
            <div class="form-group">
                <label for="Ssex">性别</label>
                <select id="Ssex" name="Ssex" required>
                    <option value="男">男</option>
                    <option value="女">女</option>
                </select>
            </div>
            <div class="form-group">
                <label for="Major">专业</label>
                <input type="text" id="Major" name="Major" required>
            </div>
            <div class="form-group">
                <label for="Choicecourse">选修课程</label>
                <input type="text" id="Choicecourse" name="Choicecourse" required>
            </div>
            <button type="submit">删除学生信息</button>
        </form>
    </div>

    <script>
        document.getElementById('deleteStudentForm').addEventListener('submit', function(event) {
            event.preventDefault();

            const formData = new FormData(this);

            fetch('/delete-student', {
                method: 'POST',
                body: JSON.stringify(Object.fromEntries(formData)),
                headers: {
                    'Content-Type': 'application/json'
                }
            })
            .then(response => response.json())
            .then(data => {
                if (data.success) {
                    alert('学生信息删除成功');
                    this.reset();
                } else {
                    alert('学生信息删除失败: ' + data.message);
                }
            })
            .catch(error => console.error('Error:', error));
        });
    </script>
</body>
</html>
